<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
    <title>ShellCheck: SC1041 – Found `eof` further down, but not on a separate line.</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
  </head>
  <body style="margin-left: auto; margin-right: auto; max-width: 800px">
    <h1>SC1041 – ShellCheck Wiki</h1>
    <a href="https://github.com/koalaman/shellcheck/wiki/SC1041">See this page on GitHub</a>
    <p style="display: none"><a href="index.html">Sitemap</a></p>
    <hr />
    <h2 id="found-eof-further-down-but-not-on-a-separate-line">Found
<code>eof</code> further down, but not on a separate line.</h2>
<pre><code>Close matches include &#39;-eof&#39; (!= &#39;eof&#39;).</code></pre>
<h3 id="problematic-code">Problematic code:</h3>
<div class="sourceCode" id="cb2"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb2-1"><a href="SC1041.html#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> <span class="op">&lt;&lt;-eof</span></span>
<span id="cb2-2"><a href="SC1041.html#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="st">Hello World</span></span>
<span id="cb2-3"><a href="SC1041.html#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="st">-eof</span></span></code></pre></div>
<h3 id="correct-code">Correct code:</h3>
<div class="sourceCode" id="cb3"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb3-1"><a href="SC1041.html#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span> <span class="op">&lt;&lt;- eof</span></span>
<span id="cb3-2"><a href="SC1041.html#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="st">Hello World</span></span>
<span id="cb3-3"><a href="SC1041.html#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="op">eof</span></span></code></pre></div>
<h3 id="rationale">Rationale:</h3>
<p>Your here document isn't properly terminated.</p>
<p>There is a line containing the terminator you've chosen, but it's not
by itself on a separate line.</p>
<p>In the example code, the script uses <code>&lt;&lt;-eof</code>, which
is the operator <code>&lt;&lt;-</code> followed by <code>eof</code>. The
script therefore looks for <code>eof</code> and skips right past the
intended terminator because it starts with a dash.</p>
<p>You will get some companion <a href="SC1042.html">SC1042</a> errors
mentioning lines that contain the string as a substring, though they all
point to the start of the here document and not the relevant line:</p>
<pre><code>In foo line 4:
Hello
^-- SC1041: Found &#39;eof&#39; further down, but not on a separate line.
^-- SC1042: Close matches include &#39;-eof&#39; (!= &#39;eof&#39;).</code></pre>
<p>Look at your here document and see which line was supposed to
terminate it. Then ensure it matches the token exactly, and that it's on
its own line with no text before or after.</p>
<p>Under Windows the error might occur due to the standard CRLF
line-ending, which is Windows-specific. Try to change the line ending
into LF.</p>
<h3 id="exceptions">Exceptions:</h3>
<p>None.</p>
<hr />
<p>Note that SC1041 and <a href="SC1042.html">SC1042</a> swapped numbers
after v0.4.6 to improve the display order. This rare instance of number
reuse was justified by them always occurring together on the same
line.</p>
    <hr />
    <p style='font-size: 80%'><a href="../index.html">ShellCheck</a> is a static analysis tool for shell scripts. This page is part of its documentation.</p>
  </body>
</html>


